package com.champ.thread;

public class StopThrowLock extends Thread{

	private SynchronizedObject object;
	public StopThrowLock(SynchronizedObject object) {
		super();
		this.object = object;
		
	}
	@Override
	public void run() {
		this.object.printString("champ", "test");
		super.run();
	}
}

class SynchronizedObject {
	private String userName = "a";
	private String password = "aa";
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	synchronized public void printString(String userName,String password) {
		try {
			this.userName = userName;
			Thread.sleep(111010);
			this.password = password;
		} catch (InterruptedException e) {
			e.printStackTrace();
			// TODO: handle exception
		}
	}
}
